package com.ztrue.framework.core.event;

import com.ztrue.framework.exception.InvalidOperationException;

/**
 * 表示一个领域事件版本无效异常
 *
 * @author zhangw
 * @date 2016/12/2 10:40
 */
public class InvalidVersionException extends InvalidOperationException {
    private String aggregateRootId;
    private String aggregateRootTypeName;
    private Long expectedVersion;
    private Long actualVersion;

    public InvalidVersionException(String aggregateRootId, String aggregateRootTypeName, Long expectedVersion, Long actualVersion) {
        super(String.format("领域事件版本无效，aggregateRootTypeName[%s]，aggregateRootId[%s]，预计版本[%d]，实际为[%d]", aggregateRootTypeName, aggregateRootId, expectedVersion, actualVersion));
        this.aggregateRootId = aggregateRootId;
        this.aggregateRootTypeName = aggregateRootTypeName;
        this.expectedVersion = expectedVersion;
        this.actualVersion = actualVersion;
    }

    public String getAggregateRootId() {
        return aggregateRootId;
    }

    public String getAggregateRootTypeName() {
        return aggregateRootTypeName;
    }

    public Long getExpectedVersion() {
        return expectedVersion;
    }

    public Long getActualVersion() {
        return actualVersion;
    }
}
